<template>
  <view>
  	<image src="../../../客服微信.jpg"></image>
  </view>	
</template>

<script>
	import {nearbyPage} from '@/common/http.api.js'
	export default {
		props: {
		  refresher: {
		    type: Boolean
		  },
		  index:{
			  type:Number,
			  default:0
		  }
		},
		data() {
			return {
				triggered: false,
				//加载更多标志
				loadMoreFlag:false,
				isEmpty:false,
				goodDataList: [],
				loadStatus: 'loadmore',
				emptyText:'',
				loadingText: '',
				loadmoreText: '',
				nomoreText: '',
				params: {
					pageNo: 1,
					pageSize: 10,
				},
			}
		},
		mounted(){
			this.refresh();
			this._freshing = false;
			this.getGoodPage();
			setTimeout(() => {
				this.triggered = true;
			}, 1000)	
		},
		methods: {
			refresh(){
				this.emptyText = this.$t('common.empty.text');
				this.loadingText = this.$t('common.loading.text');
				this.loadmoreText = this.$t('common.loadmore.text');
				this.nomoreText = this.$t('common.nomore.text');
			},
			onGoodClick(item){
				uni.navigateTo({
					url: 'pages/common/good/info?id='+item.id
				});
			},
			onPulling(e) { //自定义下拉刷新控件被下拉
				console.log("onpulling", e);
			},
			// 自定义下拉刷新被复位
			onRestore() {
			  this.triggered = 'restore'; // 需要重置
			  console.error("onRestore");
			},
			// 自定义下拉刷新被中止
			onAbort() {
			  console.error("onAbort");
			},
			onRefresh() {  //自定义下拉刷新被触发
			    debugger
			    let that = this;
			    if (that._freshing) return;
			    that._freshing = true;
			    setTimeout(() => {
			        that.triggered = false;
			        that._freshing = false;
			    }, 3000)
				console.log("onRefresh");
			},
			onButtomRefresh() { //底部刷新
				 console.log("onButtomRefresh");
			},
			getGoodPage(){
				this.loadStatus = 'loading';
				nearbyPage(this.params).then((res)=>{
					uni.stopPullDownRefresh()
					if(res.code === 0){
					  if(res.data.list.length === 0){
						this.isEmpty = true;
						this.loadStatus = 'nomore'
						this.loadMoreFlag = false;
					  }else if (res.data.list.length < 10) {
						this.loadStatus = 'nomore'
						this.loadMoreFlag = false;
					  } else {
						this.params.pageNo++;
						this.loadStatus = 'loading'
						this.loadMoreFlag = true;
					  }
					  if (this.params.pageNo > 1) {
						this.goodDataList = this.goodDataList.concat(res.data.list);
					  } else {
						this.goodDataList = res.data.list;
					  }
					}
				  }).catch(error=>{
					console.error(error)
				  })
			},
		}
	}
</script>

<style lang="scss">
.goshop-page-main-scroll {
	position: absolute;
	left: 0;
	right: 0;
	top: 0;
	bottom: 0;
	//height:calc(100vh - var(--window-top));//calc()是动态计算函数
}
.goshop-page-main-list{
	//background-color: $goshop-color-auxiliary-one;
	padding:0 20rpx;
}
</style>
